package com.itaem.community.modules.infrastructure.company.department.mapper;

import com.itaem.community.modules.infrastructure.company.department.dto.*;
import com.itaem.community.modules.infrastructure.company.department.entity.DepartmentEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * <p>项目名称: community </p>
 * <p>文件名称: DepartmentTransformer </p>
 * <p>描述: [类型描述] </p>
 * <p>创建时间: 2020/10/31 </p>
 * <p>作者信息: tomato</p>
 *
 * @author tomato
 * @version v1.0
 */
@Mapper(componentModel = "spring")
public interface DepartmentTransformer {

    /**
     * 提取信息到数据传输对象中
     *
     * @param entity  数据库实体
     * @param workers 部门下属的员工信息
     * @return 数据传输对象
     */
    DepartmentDTO entityToDto(DepartmentEntity entity, List<WorkerDTO> workers);

    /**
     * 提取数据库信息到数据传输对象中
     *
     * @param entity 数据库信息
     * @return 数据传输对象
     */
    DepartmentBriefDTO entityToBriefDto(DepartmentEntity entity);

    /**
     * 获取前端上传的创建信息到数据库实体中
     *
     * @param createDto 创建信息
     * @return 数据库实体
     */
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "deleted", expression = "java(Boolean.FALSE)")
    DepartmentEntity createDtoToEntity(DepartmentCreateDTO createDto);

    /**
     * 获取前端上传的更新信息到数据库实体中
     *
     * @param updateDto 更新信息
     * @return 数据库实体
     */
    @Mapping(target = "deleted", expression = "java(Boolean.FALSE)")
    DepartmentEntity updateDtoToEntity(DepartmentUpdateDTO updateDto);
}
